package com.csu.client.module.messageProcess;


import com.csu.client.ui.EIMMainFrame;
import com.csu.client.ui.headtree.TreeScrollPane;
import com.csu.client.ui.trayIcon.EIMTrayIcon;
import com.csu.message.BaseMessage;
import com.csu.message.MessageType;
import com.csu.message.SysMessage;

public class SysMessageProcess implements IMessageProcess {

	public void processMessage(BaseMessage message) {
		SysMessage sysMsg=(SysMessage)message;
		EIMTrayIcon trayIcon=EIMTrayIcon.getInStance();
		trayIcon.addRevedMessage(message);
		trayIcon.showIcon(message.getMsgType());
		trayIcon.setGetMsg(true);
		processSysMessage(sysMsg);
	
	}

	private void processSysMessage(SysMessage sysMsg){
		int msgContentType=sysMsg.getMsgContentType();
		final String srcQQ=sysMsg.getSrcQQ();
		switch(msgContentType){
		 case MessageType.SysMessage_Online:
			 java.awt.EventQueue.invokeLater(new Runnable() {
					public void run() {
				TreeScrollPane tree=EIMMainFrame.getInstance().getFriendTree();
				tree.changUserSate(srcQQ, true);
					}
				});
			 break;
		 case MessageType.SysMessage_Exit:
			 java.awt.EventQueue.invokeLater(new Runnable() {
					public void run() {
						TreeScrollPane tree=EIMMainFrame.getInstance().getFriendTree();
						tree.changUserSate(srcQQ, false);
					}
				});
			 break;
		}
	}
}
